package center_rpc

import (
	"common/pb"
	"context"
	"time"
)

func (cRpc *CenterRpc) DetailObject(ctx context.Context, bucket string, encKey []byte) (res *pb.ObjectDetailResponse, err error) {
	client, connClose, err := cRpc.getDrpcClient(ctx)
	if err != nil {
		return
	}
	defer connClose()
	// set a deadline for the operation
	ctx, cancel := context.WithTimeout(ctx, time.Second*10)
	defer cancel()

	res, err = client.DetailObject(ctx, &pb.ObjectDetailRequest{
		Header:             cRpc.Header(),
		Bucket:             []byte(bucket),
		EncryptedObjectKey: encKey,
	})
	return
}
